<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
	
    <div class="container-div ui-layout-center">
	    <div class="row">
	    	<div class="col-sm-12">
				<form id="operlog-form">
					<input type="hidden" id="deptId" name="deptId">
	                <input type="hidden" id="parentId" name="parentId">
					<div class="select-list gd">
						<ul>
							<li>
								登录名称123：<input type="text" name="loginName"/>
							</li>
							<li>
								手机号码：<input type="text" name="phonenumber"/>
							</li>
							<li>
								用户状态：<select name="status" th:with="type=${@dictService.selectDictData('sys_normal_disable')}">
									<option value="">所有</option>
									<option th:each="e : ${type}" th:text="${e['dictLabel']}" th:value="${e['dictValue']}"></option>
								</select>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search($('form').attr('id'))"><i class="fa fa-search"></i>&nbsp;搜索</a>
							    <a class="btn btn-success btn-rounded btn-sm" onclick="$.table.exportExcel($('form').attr('id'))"><i class="fa fa-download"></i>&nbsp;下载</a> 
							</li>
						</ul>
					</div>
				</form>
			</div>
			<div  id="toolbar">
				<a class="btn btn-sm btn-success " onclick="$.operate.add()" >
					<i class="fa fa-plus"></i> 新增
				</a>
				<a class="btn btn-sm btn-danger " onclick="$.operate.batRemove()">
					<i class="fa fa-trash-o"></i> 删除
				</a>
			</div>
				
	        <div class="col-sm-12 table-responsive table-bordered">
			    <table id="bootstrap-table" class="table-bordered" data-mobile-responsive="true"></table>
			</div>
	    </div>
    </div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
		var editFlag = [[${@permissionService.hasPermi('system:user:edit')}]];
		var removeFlag = [[${@permissionService.hasPermi('system:user:remove')}]];
		var resetPwdFlag = [[${@permissionService.hasPermi('system:user:resetPwd')}]];
        var prefix = ctx+"system/user"

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                restPwdUrl: prefix + "/restPassWord/{id}",
                sortName:"createTime",
                sortOrder: "desc",
                modalName: "用户",
                search : false,
                showExport: true,
                columns: [
                {
		            checkbox: true,  
					align: 'center'
		        },
				{
					field : 'userId', 
					title : '用户ID' ,
					visible : false,  
					align: 'center'
					
				},
                {
                	field : '',
                	align : 'center',
                	title : '序号',
                	formatter: function (value, row, index) {  
            	        return index+1;  
      	             },  
   					align: 'center'  
                },
				{
					field : 'loginName', 
					title : '登录账号', 
					visible : false,
					align: 'center'
				},
				{
					field : 'userName', 
					title : '用户昵称',  
					align: 'center',
					sortable:true
				},
				{
					field : 'dept.deptName', 
					title : '部门', 
					align: 'center'
				},
				{
					field : 'userType', 
					title : '用户类型',
					align: 'center',
					formatter: function(value, row, index) {
		                if (value == '00') {
		                    return '<span class="badge badge-primary">系统用户</span>';
		                }
		                return '<span class="badge badge-danger">未知</span>';
		            }, 
					visible : false,
					align: 'center'
				},
				{
					field : 'email', 
					title : '用户邮箱', 
					align: 'center'
					
				},
				{
					field : 'phonenumber', 
					title : '手机号码', 
					align: 'center'
				},
				{
					field : 'sex', 
					title : '用户性别',
					align: 'center',
		            formatter: function(value, row, index) {
		                if (value == '0') {
		                    return '<span class="badge badge-primary">男</span>';
		                } else if (value == '1') {
		                    return '<span class="badge badge-danger">女</span>';
		                }
		                return '<span class="badge badge-danger">未知</span>';
		            },  
					align: 'center'
				},
		        {
		            field: 'status',
		            title: '状态',
		            align: 'center',
		            formatter: function(value, row, index) {
		                if (value == '0') {
		                    return '<span class="badge badge-primary">正常</span>';
		                } else if (value == '1') {
		                    return '<span class="badge badge-danger">停用</span>';
		                }
		            },  
					align: 'center'
		        },
				{
					field : 'loginIp', 
					title : '最后登陆IP', 
					visible : false,  
					align: 'center'
				},
				{
					field : 'loginDate', 
					title : '最后登陆时间',  
					align: 'center' 
				},
				{
					field : 'createBy', 
					title : '创建者',
					visible : false,  
					align: 'center'
				},
				{
					field : 'createTime', 
					title : '创建时间',  
					align: 'center'
				},
				{
					field : 'updateBy', 
					title : '更新者', 
					visible : false,  
					align: 'center'
				},
				{
					field : 'updateTime', 
					title : '更新时间',  
					align: 'center'
				},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-success btn-xs '+editFlag+' " href="#" onclick="$.operate.edit(\'' + row.userId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs '+removeFlag+'  " href="#" onclick="$.operate.remove(\'' + row.userId + '\')"><i class="fa fa-remove"></i>删除</a> ');
                        actions.push('<a class="btn btn-info btn-xs  '+resetPwdFlag+'  " href="#" onclick="$.operate.restPwd(\'' + row.userId + '\')"><i class="fa fa-key"></i>密码重置</a>');
						return actions.join('');
		            },  
					align: 'center'
		        }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>